import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'flutter_ffmpeg_platform_interface.dart';

/// An implementation of [FlutterFfmpegPlatform] that uses method channels.
class MethodChannelFlutterFfmpeg implements FlutterFfmpegPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('com.chyuning.flutter_ffmpeg');

  @override
  Future<String> getPlatformVersion() async {
    return await methodChannel.invokeMethod<String>('getPlatformVersion') ?? '';
  }

  @override
  Future<void> ffmpegExecute(List<String> command) async {
    await methodChannel.invokeMethod('ffmpegExecute', {'command': command});
  }

  @override
  Future<String> ffprobeExecute(List<String> command) async {
    return await methodChannel.invokeMethod<String>('ffprobeExecute', {'command': command}) ?? '';
  }

  @override
  Future<void> setFontConfigPath(String fontPath) async {
    await methodChannel
        .invokeMethod('setFontConfigPath', {'fontPath': fontPath});
  }
}
